{include file="public/header"}
<!-- 表单 -->
<style>
    .layui-form-label {
        width: 100px;
    }

    .layui-input-block {
        margin-left: 130px;
    }

    .layui-form-item {
        margin-right: 30%;
    }

    .layui-upload-img {
        width: 100px;
        height: 100px;
        line-height: 100px;
        text-align: center;
        border: 1px solid #ccc;
    }

    .layui-upload-img img {
        max-width: 100%;
        max-height: 100%;
        margin: auto auto;
    }
</style>
</head>

<body>
    <div class="cBody">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">标题名称</label>
                <div class="layui-input-block">
                    <input type="text" name="title" autocomplete="off" class="layui-input" value="{$find.title}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">类型</label>
                <div class="layui-input-inline">
                    <select name="cat_id" lay-filter="cat_id">
                        {volist name="cat" id="v"}
                        <option value="{$v.id}" {$find.cat_id==$v['id'] ?"selected":''}>{php}echo
                            str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$v['level']*1);{/php}{$v.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">文章图片</label>
                <div class="layui-input-inline" style="width: 120px;">
                    <div class="layui-upload-img">
                        <img src="{$find.thum}" id="fileslist">
                    </div>
                    <input type="hidden" name="thum" autocomplete="off" class="layui-input fileslist"
                        value="{$find.thum}">
                </div>
                <a href="javascript:;" class="layui-btn layui-btn-primary"
                    onclick="OpenView('{:url('Login/uploads')}?num=1&id=fileslist','文件上传')">文件上传</a>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">摘要</label>
                <div class="layui-input-block">
                    <textarea name="abstract" class="layui-textarea">{$find.abstract}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">关键字</label>
                <div class="layui-input-block">
                    <input type="text" name="keywords" placeholder="每个关键字用英文逗号分隔," autocomplete="off"
                        class="layui-input" value="{$find.keywords}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">显示/隐藏</label>
                <div class="layui-input-block">
                    <input type="radio" name="is_show" value="1" title="显示" {$find.is_show=="1" ?"checked":''}>
                    <input type="radio" name="is_show" value="0" title="隐藏" {$find.is_show=="0" ?"checked":''}>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">内容</label>
                <div class="layui-input-block">
                    <textarea name="content" class="layui-textarea" id="LAY_demo">{$find.content}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="submitBut">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>


        <script>
            layui.use(['upload', 'form', 'layedit'], function () {
                var form = layui.form;
                var upload = layui.upload;
                var layer = layui.layer;
                var layedit = layui.layedit;
                form.render();
                layedit.set({
                    uploadImage: {
                        url: '{:url("Login/uploads")}',   //接口url
                    }
                });
                //自定义工具栏
                var index = layedit.build('LAY_demo', {
                    tool: [
                        'strong', //加粗
                        'italic', //斜体
                        'underline', //下划线
                        'del', //删除线
                        '|', //分割线
                        'left', //左对齐
                        'center', //居中
                        'right', //右对齐
                        'link', //超链接
                        'unlink', //清除链接
                        'image' //插入图片
                    ]
                });
                form.verify({
                    content: function (value) {
                        return layedit.sync(index);
                    }
                });
                //监听提交
                form.on('submit(submitBut)', function (data) {
                    data.field.content = layedit.getContent(index);
                    ajax_submit(data.field, '', 'demo');
                    return false;
                });
            });
        </script>
    </div>
</body>
{include file="public/footer"}